

<include file="public@header" />
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a >全部订单</a></li>

    </ul>

    <form class="well form-inline margin-top-20" method="get" >


        产品:
        <input type="text" class="form-control" id="goods" style="width: 120px;"  placeholder="请输入用户名">

        用户名:
        <input type="text" class="form-control" id="name" style="width: 120px;"  placeholder="请输入用户名">

        电话:
        <input type="text" class="form-control" id="mobile" style="width: 120px;"   placeholder="请输入邮箱">

        状态:
        <select class="form-control" name="category" id="status" style="width: 140px;">
            <option value='-1'>全部</option>
            <option value='0'>未核销</option>
            <option value='1'>已核销</option>
        </select> &nbsp;&nbsp;

        <input type="button" id="selectval" class="btn btn-primary" value="搜索" />
        <a class="btn btn-danger" href="{:url('tameorder/index')}">清空</a>
    </form>

    <table class="table table-hover table-bordered">

        <table class="layui-hide" id="test" lay-filter="test"></table>

        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">

            </div>
        </script>
        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
        </script>

        <!--    自定义    -->
        <script type="text/html" id="titleTpl">
            {{#  if(d.backtype ==1 ){ }} 自送 {{#  } }}
            {{#  if(d.backtype ==2 ){ }} 快递:{{d.kdorder}} {{#  } }}
            {{#  if(d.backtype ==3 ){ }} 货拉拉 {{#  } }}
        </script>


        <script>

            layui.use('table', function(){
                var table = layui.table;
                var curl="{:url('tameorder/index')}";

                var tableIns =table.render({
                    elem: '#test' ,
                    url:curl,
                    method: 'post',
                    toolbar: '#toolbarDemo',
                    title: '用户数据表',
                    totalRow: true ,
                    cols: [[
                        {field:'id', title:'ID', width:80, fixed: 'left', totalRowText: '合计'}
                        ,{field:'downs', title:'推荐人'}
                        ,{field:'name', title:'用户名'}
                        ,{field:'mobile', title:'电话'}
                        ,{field:'goodname', title:'产品'}
                        ,{field:'number', title:'数量', sort: true, totalRow: true}
                        ,{field:'backtype', title:'出货方式', templet: '#titleTpl'}
                        ,{field:'dates', title:'送达时间'}
                        ,{field:'timeb', title:'核销时间'}
                        ,{field:'user', title:'核销人'}
                        ,{field:'desc', title:'备注'}
                        ,{fixed: 'right', title:'操作', toolbar: '#barDemo'}
                    ]]
                    ,page: true
                });


                $("#selectval").click(function (){
                    var name=$("#name").val();
                    var mobile=$("#mobile").val();
                    var goodname=$("#goods").val();
                    var status=$("#status").val();
                    tableIns.reload({
                        where: { status:status,name:name,mobile:mobile,goodname:goodname } ,
                        page: { curr: 1  }
                    });
                })

                //表格工具行事件
                table.on('tool(test)', function(obj){
                    var data = obj.data;
                    //console.log(obj)
                    if(obj.event === 'del'){


                        var curl="{:url('tameorder/deleteorder')}";


                        layer.confirm('真的删除行么', function(index){




                            $.ajax({
                                url: curl,
                                data:{'id':data.id},
                                type:'post',
                                success:function (ret){
                                    obj.del();
                                    layer.close(index);
                                }
                            })


                        });
                    } else if(obj.event === 'edit'){

                        var curl="{:url('tameorder/edittame')}?id="+data.id;

                        layer.open({
                            type: 2,
                            area: ['700px', '500px'],
                            content: curl,
                            success:function (){
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                            },end:function (){
                                location.reload();
                            }
                        });


                    }
                });


            });
        </script>


    </table>

</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>